﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ping9719.DeviceCommunication.Interfaces
{
    public interface IIoTBase
    {
        /// <summary>
        /// 是否是连接的
        /// </summary>
        bool IsConnected { get; }
        /// <summary>
        /// 打开连接（如果已经是连接状态会先关闭再打开）
        /// </summary>
        /// <returns></returns>
        Result Open();
        /// <summary>
        /// 关闭连接
        /// </summary>
        /// <returns></returns>
        Result Close();
        /// <summary>
        /// 读取
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="address">地址</param>
        /// <returns>结果</returns>
        Result<T> Read<T>(string address);
        /// <summary>
        /// 读取多个
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="address">地址</param>
        /// <param name="number">数量</param>
        /// <returns>结果</returns>
        Result<IEnumerable<T>> Read<T>(string address, int number);
        /// <summary>
        /// 写入
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="address">地址</param>
        /// <param name="values">值</param>
        /// <returns>结果</returns>
        Result Write<T>(string address, T values);
        /// <summary>
        /// 写入多个
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="address">地址</param>
        /// <param name="values">值</param>
        /// <returns>结果</returns>
        Result Write<T>(string address, params T[] values);
    }
}
